package com.example.computer_exam_training_sys.controller;


import com.example.computer_exam_training_sys.entity.CoursesInfo;
import com.example.computer_exam_training_sys.entity.adminlogsInfo;
import com.example.computer_exam_training_sys.service.CoursesService;
import com.example.computer_exam_training_sys.service.admin_logsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Courses")
@CrossOrigin
public class CoursesController {

    @Autowired
    private CoursesService coursesservice;

    //http://localhost:8080/Courses/all
    // 查询所有课程
    @GetMapping("/all")
    public List<CoursesInfo> findAllCourses() {
        return coursesservice.findAll();
    }

    //http://localhost:8080/Courses/findid?course_id=5
    // 查询指定课程
    @GetMapping("/findid")
    public CoursesInfo findCoursesById(int course_id) {
        return coursesservice.findById(course_id);
    }

}
